package com.bsoft.gol.hcb.dao.accessAuth;

import ctd.persistence.annotation.DAOMethod;
import ctd.persistence.annotation.DAOParam;
import hcn.base.accessAuth.AcDoctorAuthEntity;
import java.util.Date;
import java.util.List;
import org.atag.dao.ext.HibernateExtendDAO;
public abstract class AcDoctorAuthDAO extends HibernateExtendDAO<AcDoctorAuthEntity> {
    public AcDoctorAuthDAO() {this.setKeyField("authId");}

    /**
     * 查询全部数据
     * @param userId
     * @param mpiId
     * @param bizType
     * @param resourceType
     * @param authType
     * @return
     */
    @DAOMethod(sql = "from AcDoctorAuthEntity where authActive=0 and userId=:userId and mpiId=:mpiId and bizType=:bizType and resourceType=:resourceType and authType=:authType")
    public abstract AcDoctorAuthEntity getAcDoctorAuth(@DAOParam("userId") String userId,@DAOParam("mpiId") String mpiId,@DAOParam("bizType") String bizType,
        @DAOParam("resourceType") String resourceType,@DAOParam("authType") String authType);

    @DAOMethod(sql = "from AcDoctorAuthEntity where authActive=0 and userId=:userId and mpiId=:mpiId and bizType=:bizType and resourceType=:resourceType and authType=:authType and (authExpireTime>=:authExpireTime or authExpireTime is null)")
    public abstract List<AcDoctorAuthEntity> queryAcDoctorAuth(@DAOParam("userId") String userId, @DAOParam("mpiId") String mpiId, @DAOParam("bizType") String bizType,
                                                             @DAOParam("resourceType") String resourceType, @DAOParam("authType") String authType,@DAOParam("authExpireTime") Date authExpireTime);

    /**
     * 查询单条有效记录
     * @param userId
     * @param mpiId
     * @param bizType
     * @param resourceType
     * @param authType
     * @return
     */
    @DAOMethod(sql = "from AcDoctorAuthEntity where authActive=0 and resourceId=:resourceId and userId=:userId and " +
            "mpiId=:mpiId and bizType=:bizType and resourceType=:resourceType and authType=:authType")
    public abstract AcDoctorAuthEntity getAcDoctorAuthOne(@DAOParam("resourceId") String resourceId,
                                                       @DAOParam("userId") String userId,@DAOParam("mpiId") String mpiId,@DAOParam("bizType") String bizType,
                                                       @DAOParam("resourceType") String resourceType,@DAOParam("authType") String authType);
    /**
     * 查询单条有效记录
     * @param userId
     * @param mpiId
     * @param bizType
     * @param resourceType
     * @param authType
     * @return
     */
//    @DAOMethod(sql = "from AcDoctorAuthEntity where authActive=0 and resourceId=:resourceId and userId=:userId and " +
//            "mpiId=:mpiId and bizType=:bizType and resourceType=:resourceType and authType=:authType order by update_time desc")
//    public abstract List<AcDoctorAuthEntity> queryAcDoctorAuthOne(@DAOParam("resourceId") String resourceId,
//                                                       @DAOParam("userId") String userId,@DAOParam("mpiId") String mpiId,@DAOParam("bizType") String bizType,
//                                                       @DAOParam("resourceType") String resourceType,@DAOParam("authType") String authType);
    @DAOMethod(sql = "from AcDoctorAuthEntity where authActive=0 and resourceId=:resourceId and userId=:userId and " +
            "mpiId=:mpiId and bizType=:bizType and resourceType=:resourceType and authType=:authType and (authExpireTime>=:authExpireTime or authExpireTime is null)")
    public abstract List<AcDoctorAuthEntity> queryAcDoctorAuthOne(@DAOParam("resourceId") String resourceId,
                                                       @DAOParam("userId") String userId,@DAOParam("mpiId") String mpiId,@DAOParam("bizType") String bizType,
                                                       @DAOParam("resourceType") String resourceType,@DAOParam("authType") String authType,@DAOParam("authExpireTime") Date authExpireTime);
}